// pages/device/deviceInfo.ts
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    alertSwitch: false,
    udpSwitch: true,
    showAction: false,
    deviceID: null,
    contractList: [
      { id: 0, url: app.getImgUrl('contract.webp'), name: '合同一' },
      { id: 1, url: app.getImgUrl('contract.webp'), name: '合同二' },
      { id: 2, url: app.getImgUrl('contract.webp'), name: '合同三' },
      { id: 3, url: app.getImgUrl('contract.webp'), name: '合同四' },
      { id: 4, url: app.getImgUrl('contract.webp'), name: '合同五' },
    ],
    markerImg: app.getImgUrl('location.svg'),
    actions: [
      {
        name: '编辑',
        id: 0,
      },
      {
        name: '诊断',
        id: 1
      }
    ],
    deviceInfo: {},
    projectInfo: {},
    customerInfo: {},
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(option) {
    if (option.id) {
      this.setData({
        deviceID: option.id
      })
      this.getDeviceInfo()
    } else {
      wx.showToast({
        title: '参数错误',
        icon: 'fail'
      })
      setTimeout(() => {
        wx.navigateBack()
      }, 500);
    }
  },
  //获取设备信息
  getDeviceInfo() {
    app.axios('device', {
      op: 'ajaxDeviceDetail',
      id: this.data.deviceID
    }).then(res => {
      if (res.code) {
        this.setData({
          deviceInfo: res.item
        })
      }
    })
  },
  onBack(){
    wx.navigateBack()
  },
  onChange({ detail }) {
    // 需要手动对 checked 状态进行更新
    this.setData({ checked: detail });
  },
  onChange1({ detail }) {
    // 需要手动对 checked 状态进行更新
    this.setData({ checked: detail });
  },
  openActionList() {
    this.setData({ showAction: true });
  },
  closeAction() {
    this.setData({ showAction: false });
  },
  handleActionSelect(e) {
    console.log(e.detail.id, 'eeeeeeeeeeeeeeeeeeeeeee')
  }
})